<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <p:panel header="PRACTICANTES" style="border: none;">

        <br/>
        <div align="center">
            <p><h:outputText value="LISTADO DE PRACTICANTES" style="font-weight: bold; font-size: 18px; color:#069;"/></p>

            <h:form id="formSearchId">

                <p:toolbar>  
                    <p:toolbarGroup align="left">  
                        <p:inputText id="textNumber" value="#{practiceBean.filterValue}"
                                     style="margin-bottom: 10px;"/> 
                        <pe:keyFilter for="textNumber" mask="num"/> 
                        <p:watermark for="textNumber" value="Exm: 0020110452" />

                        <p:commandButton icon="ui-icon-zoomin" 
                                         value="Buscar"
                                         title="Actualizar"
                                         action="#{practiceBean.filterTablePractice}"/>  
                         
                    </p:toolbarGroup>  

                    <p:toolbarGroup align="right">   
                        <p:outputLabel value="Filtro: "/>
                        <p:selectOneMenu value="#{practiceBean.filterCombo}">
                            <f:selectItem itemLabel="TODOS" itemValue="TODOS"/>
                            <f:selectItems value="#{practiceBean.listStateString}" var="stateString"
                                           itemLabel="#{stateString}" itemValue="#{stateString}"/>
                            <p:ajax event="valueChange"/>
                        </p:selectOneMenu>
                    </p:toolbarGroup>  

                </p:toolbar> 
            </h:form>
            <br/>
            <h:form id="formTablePracticeId">

                <p:dataTable id="tablePractice" value="#{practiceBean.listHistoryPracticeNoRepeat}" var="practice"
                             emptyMessage="No se Encontro Registros..." paginator="true" rows="10">

                    <p:column style="width: 3%">  
                        <p:menuButton id="button" style="width: 30px; height: 30px" value=" ">
                            <p:menuitem value="Editar" icon="ui-icon-pencil" update=":panelCenter" rendered="#{!practice.idPractice.amplificated}"
                                        onstart="PF('blockUI').block();" oncomplete="PF('blockUI').unblock();" ajax="false"
                                        action="#{newPracticeBean.initBeanEdit()}">
                                <f:setPropertyActionListener value="#{practiceBean.editPractice(practice.idPractice.id)}" target="#{newPracticeBean.practice}"/>
                                <f:setPropertyActionListener value="./content/new_practice.xhtml" target="#{indexLoginBean.navigation}"/>
                            </p:menuitem>
                            <p:separator/>
                            <p:menuitem value="Ver Detalles" icon="ui-icon-contact" update=":panelCenter" 
                                        onstart="PF('blockUI').block();" oncomplete="PF('blockUI').unblock();">
                                <f:setPropertyActionListener value="#{practiceBean.setSendPractice(practice.idPractice)}" target="#{practiceDetailBean.practice}"/>
                                <f:setPropertyActionListener value="#{true}" target="#{practiceDetailBean.showStatePratice}"/>
                                <f:setPropertyActionListener value="./content/detail_practice.xhtml" target="#{indexLoginBean.navigation}"/>
                            </p:menuitem>
                            <p:menuitem value="Procesar" icon="ui-icon-wrench" update=":panelCenter"
                                        action="#{practiceProcessBean.initCollection()}">
                                <f:setPropertyActionListener value="#{practiceBean.setSendPractice(practice.idPractice)}" target="#{practiceProcessBean.practice}"/>
                                <f:setPropertyActionListener value="#{true}" target="#{practiceProcessBean.globalUpdate}"/>
                                <f:setPropertyActionListener value="./content/process_practice.xhtml" target="#{indexLoginBean.navigation}"/>
                            </p:menuitem>
                            <p:separator/>
                            <p:menuitem value="Ampliar Practica" icon="ui-icon-clock" 
                                        rendered="#{!practice.idPractice.amplificated}"
                                        oncomplete="extenderPractica.show();" update=":extenderPracticaId"
                                        action="#{practiceBean.verifiAmplification}">
                                <f:setPropertyActionListener value="#{practice.idPractice}" target="#{practiceBean.practice}"/>
                            </p:menuitem>
                        </p:menuButton> 
                    </p:column> 

                    <p:column headerText="ALUMNO"> 
                        <h:outputText value="#{practice.idPractice.codeAlumn}"/>
                    </p:column>

                    <p:column headerText="PROYECTO"> 
                        <h:outputText value="#{practice.idPractice.titleProject}"/>
                    </p:column>

                    <p:column headerText="COMPAÑIA"> 
                        <h:outputText value="#{practice.idPractice.idCompany.name}"/>
                    </p:column>

                    <p:column headerText="INICIO"> 
                        <h:outputText value="#{practice.idPractice.startDate}">
                            <f:convertDateTime type="date" pattern="dd-MM-yyyy"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="FIN"> 
                        <h:outputText value="#{practice.idPractice.endDate}">
                            <f:convertDateTime type="date" pattern="dd-MM-yyyy"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="ESTADO">
                        <h:outputText value="#{practice.idState.name}"/>
                    </p:column>
                    <p:column headerText="Asesor">
                        <h:outputText value="#{practice.idPractice.idAdviserPractice.nameAdviser}"/>
                    </p:column>

                </p:dataTable>
            </h:form>
        </div>
    </p:panel>


    <p:dialog id="extenderPracticaId" widgetVar="extenderPractica" appendTo="@(body)"
              closeOnEscape="true" modal="true" header="Extender Practicas">
        <div align="center">
            <h:outputText value="Código Alumno: #{practiceBean.practice.codeAlumn}"/>
        </div> 
        <h:form><br/>
            <p:separator/>
            <h:outputText value="Total de amplificaciones realizadas: #{practiceBean.practice.amplificationPracticeList.size()}"/><br/>
            <h:outputText value="Dia Inicial:  #{practiceBean.practice.startDate}">
                <f:convertDateTime parent="dd/MM/yyyy"/>
            </h:outputText><br/>
            <h:outputText value="Dia Final: #{practiceBean.practice.dateFinal}">
                <f:convertDateTime parent="dd/MM/yyyy"/>
            </h:outputText><br/>
            <h:outputText value="Cuantos meses desea agregar? "/>
            <p:spinner id="spinnerBasic" max="3" min="1" size="2" value="#{practiceBean.months}"/>
            <br/><br/>
            <p:inputTextarea value="#{practiceBean.movitveAmplification}" autoResize="false"
                             required="true"/>
            <div align="center">
                <p:commandButton value="Guardar Información" oncomplete="extenderPractica.hide();"
                                 action="#{practiceBean.saveAmplification}"/>
            </div>
        </h:form>

    </p:dialog>

</ui:composition>
